
from rest_framework.response import Response
from rest_framework.viewsets import ModelViewSet
from meiduo_admin.serializers.image_serializers import *
from goods.models import SKUImage,SKU
from meiduo_admin.custom_paginations import MyPage



class ImageViewSet(ModelViewSet):
    queryset = SKUImage.objects.all()
    serializer_class = ImageModelSerializer
    pagination_class = MyPage


    def simple(self, request):
        # 序列化sku商品对象
        sku_queryset = SKU.objects.all()
        serializer = ImageSKUSimpleSerializer(instance=sku_queryset, many=True)
        return Response(serializer.data)